<?php 
$link = mysql_connect('localhost', 'root', '');
//$link = mysql_connect('aecabill.accountsupportmysql.com', 'aeca', 'fArC5YyyG8NT9wdC5LXP');
if (!$link) { 
     die('There appeared to be an error while connecting to the website database: ' . mysql_error()); 
}
mysql_select_db(aeca);

$cmpyID = $_POST['cid'];
$query = "select * from tbl_companies where c_id = $cmpyID";
$result = mysql_query($query);
$c_res = mysql_fetch_array($result);

$cid = $c_res['ct_id'];
$ct_query = "select tbl_companies.ct_id,tbl_company_type.ct_company from tbl_companies inner join tbl_company_type on tbl_companies.ct_id = tbl_company_type.ct_id where tbl_companies.ct_id = $cid";
$ct_result = mysql_fetch_array(mysql_query($ct_query));

$rptid = $c_res['reporting_type'];
$report_query = "select tbl_companies.reporting_type,tbl_reporting_type.reporting_type from tbl_companies inner join tbl_reporting_type on tbl_companies.reporting_type = tbl_reporting_type.rpt_id where tbl_companies.reporting_type = $rptid";
$report_result = mysql_fetch_array(mysql_query($report_query));
?>
<script>
   $(function() {  
   $(".ecsubmit").click(function() { 
     // validate and process form here
     $("#editCompInfofrm").validate(); 
     var name = 'EditCmpyInfo';
     var cid = $("#cid").val();
     var c_billing_address1 = $("#c_billing_address1").val();
     var c_billing_address2 = $("#c_billing_address2").val();
     var c_billing_city = $("#c_billing_city").val();
     var c_billing_state = $("#c_billing_state").val();
     var c_billing_zipcode = $("#c_billing_zipcode").val();
     var c_billing_country = $("#c_billing_country").val();
     var c_phone_number = $("#c_phone_number").val();
     var c_phone_extension = $("#c_phone_extension").val();
     var c_fax_number = $("#c_fax_number").val();
	     $.post("/aec1/pages/update_cprofile.php",{name:name,cid:cid,c_billing_address1:c_billing_address1,c_billing_address1:c_billing_address1,c_billing_address2:c_billing_address2,c_billing_city:c_billing_city,c_billing_state:c_billing_state,c_billing_zipcode:c_billing_zipcode,c_billing_country:c_billing_country,c_billing_country:c_billing_country,c_phone_number:c_phone_number,c_phone_extension:c_phone_extension,c_fax_number:c_fax_number},function(data){
	     	$( "#dialog:ui-dialog" ).dialog( "destroy" );
			$( "#dialog-message1" ).dialog({
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog( "close" );
					window.location = "index.php?page=companyinfo";
				}
			}
			});
	     });
	     return false;
   });  
 }); 
  </script>	
  <!-- ui-dialog -->
<div id="dialog-message1" title="Success Message" style="display:none;">
	<p>
		<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
		The Company Profile Information has been updated Successfully.
	</p>
</div>
<h4>Edit Company Information</h4>
<form method="post" id="editCompInfofrm" action="">
<table cellpadding="4">
	<tr>
		<td><strong>Company Name* :</strong></td>
		<td><span style="color:#0762A3"><?=$c_res['c_name'];?></span></td>
	</tr>
	<tr>
		<td><strong>Company Nickname* :</strong></td>
		<td><span style="color:#0762A3"><?=$c_res['c_nickname'];?></span></td>
	</tr>
	<tr>
		<td><strong>Company Type :</strong></td>
		<td><span style="color:#0762A3"><?=$ct_result['ct_company'];?></span></td>
	</tr>
	<tr>
		<td><strong>Reporting Type :</strong></td>
		<td><span style="color:#0762A3"><?=$report_result['reporting_type'];?></span></td>
	</tr>
	<tr>
		<td><strong>Billing Address1 :</strong></td>
		<td><input type="text" name="c_billing_address1" value="<?=$c_res['c_billing_address1'];?>" id="c_billing_address1"/></td>
	</tr>
	<tr>
		<td><strong>Billing Address2 :</strong></td>
		<td><input type="text" name="c_billing_address2" value="<?=$c_res['c_billing_address2'];?>" id="c_billing_address2"/></td>
	</tr>
	<tr>
		<td><strong>City :</strong></td>
		<td><input type="text" name="c_billing_city" value="<?=$c_res['c_billing_city'];?>" id="c_billing_city"/></td>
	</tr>
	<tr>
		<td><strong>State :</strong></td>
		<td><input type="text" name="c_billing_state" value="<?=$c_res['c_billing_state'];?>" id="c_billing_state"/></td>
	</tr>
	<tr>
		<td><strong>Zip Code :</strong></td>
		<td><input type="text" name="c_billing_zipcode" value="<?=$c_res['c_billing_zipcode'];?>" id="c_billing_zipcode"/></td>
	</tr>
	<tr>
		<td><strong>Country :</strong></td>
		<td><input type="text" name="c_billing_country" value="<?=$c_res['c_billing_country'];?>" id="c_billing_country"/></td>
	</tr>
	<tr>
		<td><strong>Phone Number :</strong></td>
		<td><input type="text" name="c_phone_number" class="number" value="<?=$c_res['c_phone_number'];?>" id="c_phone_number"/></td>
	</tr>
	<tr>
		<td><strong>Extension :</strong></td>
		<td><input type="text" name="c_phone_extension" class="number" value="<?=$c_res['c_phone_extension'];?>" id="c_phone_extension"/></td>
	</tr>
	<tr>
		<td><strong>Fax Number :</strong></td>
		<td><input type="text" name="c_fax_number" class="number" value="<?=$c_res['c_fax_number'];?>" id="c_fax_number"/></td>
	</tr>
	<tr>
		<td>&nbsp;<input type="hidden" value="company_info" name="cmpy_info" /></td>
		<td>
			<input type="submit" value="submit" name="submit" class="ecsubmit"/>
			<input type="button" value="Cancel" name="cancel" onclick="location.href='index.php?page=edit-companyinfo'"/>
		</td>
	</tr>
	<input type="hidden" name="chidden" value="<?=$cmpyID?>" id="cid"/>
</table>
</form>